//
//  COCallTopView.swift
//  CocoProject
//
//  Created by Vill on 2023/11/15.
//

import UIKit

typealias videoTopblock = (_ type : NSInteger)->Void

class COCallTopView: UIView {

    var callBack:videoTopblock?

    lazy var closeBtn: UIButton = {
        let i = UIButton()
        i.setImage(KImaged("coco_video_close"), for: .normal)
        i.addTarget(self, action: #selector(closeAction), for: .touchUpInside)
        return i
    }()
    
    lazy var nameLbl: UILabel = {
        let name = UILabel()
        name.textColor = .white
        name.font =  UIFont.pingfangFont(ofSize: PTW(26), weight: .medium)
        return name
    }()
    
    lazy var timeLbl: UILabel = {
        let name = UILabel()
        name.textColor = .white
        name.font =  UIFont.pingfangFont(ofSize: PTW(17), weight: .medium)
        return name
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        addUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    @objc func closeAction(sender:UIButton){
        if self.callBack != nil {
            self.callBack!(1)
        }
    }

    
    func addUI(){
        addSubview(closeBtn)
        addSubview(nameLbl)
        addSubview(timeLbl)
        closeBtn.snp.makeConstraints { make in
            make.size.equalTo(PTW(50))
            make.leading.equalToSuperview().offset(PTW(20))
            make.top.equalTo(statusBarHeight)
        }
        
        nameLbl.snp.makeConstraints { make in
            make.leading.equalTo(closeBtn)
            make.top.equalTo(closeBtn.snp.bottom).offset(PTW(12))
            make.height.equalTo(PTW(35))
        }
        timeLbl.snp.makeConstraints { make in
            make.leading.equalTo(closeBtn)
            make.top.equalTo(nameLbl.snp.bottom).offset(PTW(4))
            make.height.equalTo(PTW(21))
        }
    }
    
}
